import { mapGetters } from 'vuex'

//导出一个 mixin 对象
export default {
  computed: {
    ...mapGetters('m_cart', ['total'])
  },
  watch: {
    total() {
      this.setBadge()
    }
  },
  onShow() {
    this.setBadge()
  },
  methods: {
    setBadge() {
              uni.setTabBarBadge({
                index: 2, // 始终指向购物车 tab 的索引
                text: this.total + ''
              })
            }
  }
}